var _ajax = require('../../utils/ajax'); // 请求函数
var _Server = require('../../utils/server'); // 地址
var WxParse = require('../../wxParse/wxParse'); // 富文本转化插件
Page({
    /**
     * 页面的初始数据
     */
    data: {

    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        var that = this;
        _ajax.getCourseDetail(options.courseId,function(data){
            if (data.code == 0) {
                this.setData({
                    indexUrl: _Server.url,
                    courseDetail: data.data,
                    courseId: options.courseId
                });
                var article = data.data.content;
                WxParse.wxParse('article', 'html', article, that, 5);
            }
        },this);
    },
    // 位置导航
    fnPositionNavigation: function (){
        var that = this;
        wx.openLocation({
            latitude: Number(that.data.courseDetail.lat),
            longitude: Number(that.data.courseDetail.lng),
            scale: 18
        });
    },
    // 立即报名
    fnCurseInformation: function(){
        var that = this;
        wx.navigateTo({
            url: '../courseInformation/courseInformation?courseId=' + that.data.courseId,
        });
    }
})